According to an H.264 standard arranged for encoding/decoding a moving picture, the encoding/decoding is performed on the basis of a unit of macro blocks or a unit of a sub-block. One frame includes a plurality of macro blocks, and the sub-block is acquired by dividing a macro block into two or four sub-blocks. The encoding and decoding are carried out based on temporal prediction and spatial prediction. Temporal prediction is predicting motion of the macro blocks of a current frame by referring to macro blocks of adjacent frames. Spatial prediction is predicting a macro block of a current frame to be encoded based on adjacent macro blocks within the current frame.
The spatial prediction is also referred to as intra prediction. The intra predication takes advantage of a feature that adjacent pixels of a pixel to be predicted is highly likely to have a similar value. According to the H.264 standard, a pixel value of a current block is predicted based on a prediction mode considering nine directionalities.
FIG. 1 is a view showing an intra prediction mode for 4×4 blocks and 8×8 blocks in the H.264 standard. There are nine prediction modes according to the prediction direction: a vertical mode (mode 0), a horizontal mode (mode 1), a DC mode (mode 2), a Diagonal_Down_Left mode (mode 3), a Diagonal_Down_Right mode (mode 4), a Vertical_Right mode (mode 5), a Horizontal_Down mode (mode 6), a Vertical_Left mode (mode 7), and a Horizontal_Up mode (mode 8). The arrows signify prediction directions. Hereinafter, a prediction process in the vertical mode and the horizontal mode when intra prediction is performed onto 4×4 blocks will be described.
FIG. 2 is a view for describing a pixel prediction process in the vertical mode performed onto 4×4 blocks 300. As shown in FIG. 2, pixels a, e, i, and m 302, 304, 306 and 308 are predicted from an adjacent pixel A in the vertical direction. In the same way, pixels b, f, j and n are predicted from a pixel B, and pixels c, g, k and o are predicted from a pixel C, while pixels d, h, l and p are predicted from a pixel D.
FIG. 3 is a view for describing a pixel prediction process in the horizontal mode performed onto 4×4 blocks 300. As shown in FIG. 3, pixels a, b, c and d 312, 314, 316 and 318 are predicted from an adjacent pixel I in the horizontal direction. In the same way, pixels e, f, g and h are predicted from a pixel J, and i, j, k and l are predicted from a pixel K pixels, while pixels m, n, o and p are predicted from a pixel L.
Meanwhile, a conventional moving picture encoder performs entropy encoding by performing Discrete Cosine Transform (DCT) and quantization onto a residue signal, which is obtained by differentially dividing a predicted signal and a current signal, to thereby produce coefficients and performing zigzag scanning onto the coefficients.
However, the correlation of the residue signal is likely to be high in a horizontal direction or a vertical direction according to whether the prediction mode is a horizontal mode or a vertical mode. Therefore, the conventional encoding method using a fixed zigzag scanning has a drawback that it is not appropriate for acquiring a high compression rate.